package com.xm;

/**
 * Author：xm
 * Project：interview
 * Date：2025/10/13  14:35
 */

public class _02_MyLinkedList {

    static _02_ListNode head;

    public static void main(String[] args) {
        new _02_MyLinkedList().add(1);
        new _02_MyLinkedList().add(2);
        new _02_MyLinkedList().add(3);

        System.out.println(head);
        System.out.println(head.next);
        System.out.println(head.next.next);

        System.out.println(head.next.next.data);
        System.out.println(head.next.next.next);
    }

    public void add(int data) {
        _02_ListNode newNode = new _02_ListNode(data);
        if (head == null) {
            head = newNode;
        } else {
            _02_ListNode current = head;
            while (current.next != null) {
                current = current.next;
            }
            current.next = newNode;
        }
    }
}
